package com.achun.ximalayamvvm

import android.app.Application
import android.content.Context
import com.ximalaya.ting.android.opensdk.constants.DTransferConstants
import com.ximalaya.ting.android.opensdk.datatrasfer.AccessTokenManager
import com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest
import com.ximalaya.ting.android.opensdk.datatrasfer.IDeviceInfoProvider
import com.ximalaya.ting.android.opensdk.player.XmPlayerManager





class BaseApplication:Application() {
    companion object{

        fun getAppContext():Context{
            return context!!
        }
        var context:Context?=null
    }

   var provider= object:IDeviceInfoProvider{
        override fun oaid(): String {
        return "null"
        }

        override fun imei(): String {
            return ""
        }

        override fun macAddress(): String {
            return ""
        }

        override fun serial(): String {
            return ""
        }

    }
    override fun onCreate() {
        super.onCreate()
        context= baseContext
        var mXimalaya = CommonRequest.getInstanse()
        if (DTransferConstants.isRelease) {
            val mAppSecret = "8646d66d6abe2efd14f2891f9fd1c8af"
            mXimalaya.setAppkey("9f9ef8f10bebeaa83e71e62f935bede8")
            mXimalaya.setPackid("com.app.test.android")
            mXimalaya.init(this, mAppSecret,provider)
        } else {
            val mAppSecret = "ff31ae8153185db13b5f5393cae962c4"
            mXimalaya.setAppkey("be022ee6e9f19df55c4a6eb836b7b0b9")
            mXimalaya.setPackid("android.test")
            mXimalaya.init(this, mAppSecret,provider)
        }

        //初始化播放器
        //初始化播放器
        XmPlayerManager.getInstance(context).init()
        XmPlayerManager.getInstance(context).setBreakpointResume(false)




    }

    override fun onTerminate() {
        super.onTerminate()
        XmPlayerManager.release()
    }
}